/**
 * 
 */
package com.nwpusp.controller.actions;

import com.nwpusp.model.GameModel;
import com.nwpusp.model.players.Player;
import com.nwpusp.model.players.PlayerManager;
import com.nwpusp.model.session.ConnectionId;

/**
 * @author JustinCao
 *
 */
public class PlayerRemoveAction extends PlayerAction {

	public PlayerRemoveAction(ConnectionId cid) {
		super(cid);
	}
	
	@Override
	public String toString() {
		return "Remove cid " + Long.toString(cid.getCid());
	}
	
	@Override
	public void Invoke(GameModel m) {
		PlayerManager pm = m.getPlayerManager();
		Player p = pm.getPlayer(cid);
		if(p != null) {
			m.getScenario().removeCharacter(p.getCh());
		}
		pm.removePlayer(cid);
	}

}
